home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9216 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: dispatch.news.demon.net!demon!redifon.demon.co.uk
  2. From: Guy Pickering <gp@redifon.demon.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Mutexes make const functions impossible!?
  5. Date: Thu, 29 Feb 1996 12:26:10 GMT
  6. Organization: Redifon MEL Ltd
  7. Message-ID: <825596770.4813@redifon.demon.co.uk>
  8. NNTP-Posting-Host: redifon.demon.co.uk
  9. X-NNTP-Posting-Host: redifon.demon.co.uk
  10. X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.3_U1 sun4c)
  11. MIME-Version: 1.0
  12. X-URL: news:comp.lang.c++
  13. Content-Transfer-Encoding: 7bit
  14. Content-Type: text/plain; charset=us-ascii
  15.  
  16. Usually, my classes have a number of const functions for getting internal
  17. data (e.g. getWidth(), getNumEvents()). My problem is that when I wish
  18. to be thread-safe, I need to lock and unlock a mutex every time I access
  19. internal data. This means my functions can no longer be const because the
  20. mutex member is being locked and unlocked.
  21.  
  22. Is this a situation where the const'ness should be cast away, or am I
  23. dammed to throw away all const'ness from thread-safe functions. Or is
  24. there another solution?
  25.  
  26. Thank you for your time.
  27.  
  28. Guy
  29.  
  30. -- 
  31. Name: Guy Pickering B.Eng A.M.I.E.E
  32. Position: Software Engineer
  33. Company: Redifon MEL Ltd, Newton Rd, Crawley, 
  34.          West Sussex, RH10 2TU. ENGLAND
  35. Tel:  +44 (0)1293 518855   Fax: +44 (0)1293 530101
  36. Mobile: +44 (0)973 129362 (Orange)
  37.  
  38.